﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace WL.Think.Sample.Migrations
{
    /// <inheritdoc />
    public partial class _20260919_ModifyDb : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AppDeviceCategory",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "主键"),
                    IsHost = table.Column<bool>(type: "boolean", nullable: false, comment: "是否主机分类"),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true, comment: "租户ID"),
                    Builtin = table.Column<bool>(type: "boolean", nullable: false, comment: "内置数据"),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false, comment: "并发令牌"),
                    Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false, comment: "名称"),
                    Path = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false, comment: "路径"),
                    ParentId = table.Column<Guid>(type: "uuid", nullable: true, comment: "上级ID"),
                    IsActive = table.Column<bool>(type: "boolean", nullable: false, comment: "是否启用"),
                    Description = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true, comment: "描述"),
                    Index = table.Column<int>(type: "integer", nullable: false, comment: "排序")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppDeviceCategory", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AppDeviceCategory_AppDeviceCategory_ParentId",
                        column: x => x.ParentId,
                        principalTable: "AppDeviceCategory",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppDeviceCategory_ParentId",
                table: "AppDeviceCategory",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_AppDeviceCategory_Path",
                table: "AppDeviceCategory",
                column: "Path");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AppDeviceCategory");
        }
    }
}
